#!/usr/bin/env python
# -*- coding: utf-8 -*-
# time: 2023/11/3 10:44
# file: txt_to_pkl.py
# author: Yingxiao Zhang

import pickle

data = []
with open('E:\桌面\huggingface\speech_paraformer_asr-en-16k-vocab4199-pytorch/tokens.txt', 'r', encoding='utf-8') as f:
    for line in f.readlines():
        data.append(line.strip())
# print(list(result['token_list']), type(result['token_list']))
print(len(data))


#wb是覆盖写，如果需要追加，则为‘ab'
f = open('resources_en2/models/token_list.pkl','wb')
#待写入数据
#写入
data= pickle.dump(data,f,-1)
#关闭文件
f.close()

f = open('resources_en2/models/token_list.pkl','rb')
data = pickle.load(f)
print(data)
print(len(data))
f.close()